﻿#define _CRT_SECURE_NO_WARNINGS 1

class MyQueue {
public:
    MyQueue()
    {}

    void push(int x)
    {
        pushS.push(x);
    }

    int pop()
    {
        if (popS.empty())
        {
            while (!pushS.empty())
            {
                popS.push(pushS.top());
                pushS.pop();
            }
        }
        int n = popS.top();
        popS.pop();
        return n;
    }

    int peek()
    {
        if (popS.empty())
        {
            while (!pushS.empty())
            {
                popS.push(pushS.top());
                pushS.pop();
            }
        }
        return popS.top();
    }

    bool empty()
    {
        return pushS.empty() && popS.empty();
    }
private:
    stack<int> pushS;
    stack<int> popS;
};

